General Fixture
^^^^^
**Definition:**
* Occurs when a test case fixture is too general and the test methods only access part of it. A test setup/fixture method that initializes fields that are not accessed by test methods indicates that the fixture is too generalized. A drawback of it being too general is that unnecessary work is being done when a test method is run.
**Also Known As:**
* Badly Used Fixture
**Code Example:**
.. code-block:: java
public void testGetFlightsByFromAirport_OneOutboundFlight() throws Exception {
setupStandardAirportsAndFlights();
FlightDto outboundFlight = findOneOutboundFlight();
// Exercise System
List flightsAtOrigin = facade.getFlightsByOriginAirport(
outboundFlight.getOriginAirportId());
// Verify Outcome
assertOnly1FlightInDtoList( "Flights at origin", outboundFlight,
flightsAtOrigin);
}
public void testGetFlightsByFromAirport_TwoOutboundFlights() throws Exception {
setupStandardAirportsAndFlights();
FlightDto[] outboundFlights = findTwoOutboundFlightsFromOneAirport();
// Exercise System
List flightsAtOrigin = facade.getFlightsByOriginAirport(
outboundFlights[0].getOriginAirportId());
// Verify Outcome
assertExactly2FlightsInDtoList( "Flights at origin", outboundFlights,
flightsAtOrigin);
}
}
**References:**
.. admonition:: Quality attributes
* :octicon:`file-code;1em` - Code Example
* :octicon:`comment-discussion;1em` - Cause and Effect
* :octicon:`graph;1em` - Frequency
* :octicon:`sync;1em` - Refactoring
* `A preliminary evaluation on the relationship among architectural and test smells `_
* `A survey on test practitioners' awareness of test smells `_
* `An Empirical Study into the Relationship Between Class Features and Test Smells `_ :octicon:`graph;1em`
* `An Exploratory Study on the Refactoring of Unit Test Files in Android Applications `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em`
* `An analysis of information needs to detect test smells `_ :octicon:`comment-discussion;1em`
* `An empirical investigation into the nature of test smells `_ :octicon:`sync;1em`
* `An exploratory study of the relationship between software test smells and fault-proneness `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em`
* `Are test smells really harmful? An empirical study `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em`
* `Assessing diffusion and perception of test smells in scala projects `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em`
* `Automated Detection of Test Fixture Strategies and Smells `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em`
* `Automatic Identification of High-Impact Bug Report by Product and Test Code Quality `_
* `Automatic Test Smell Detection Using Information Retrieval Techniques `_ :octicon:`graph;1em`
* `Automatic generation of smell-free unit tests `_ :octicon:`comment-discussion;1em`
* `Categorising Test Smells `_ :octicon:`graph;1em`
* `Characterizing High-Quality Test Methods: A First Empirical Study `_ :octicon:`graph;1em`
* `Characterizing the Relative Significance of a Test Smell `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em`
* `Detecting redundant unit tests for AspectJ programs `_ :octicon:`comment-discussion;1em`
* `Enhancing developers’ awareness on test suites’ quality with test smell summaries `_
* `Handling Test Smells in Python: Results from a Mixed-Method Study `_
* `How are test smells treated in the wild? A tale of two empirical studies `_ :octicon:`graph;1em`
* `Investigating Severity Thresholds for Test Smells `_ :octicon:`comment-discussion;1em`
* `Just-In-Time Test Smell Detection and Refactoring: The DARTS Project `_ :octicon:`sync;1em`
* `Let’s not `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`sync;1em`
* `Obscure Test `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`sync;1em`
* `On The Detection of Test Smells: A Metrics-Based Approach for General Fixture and Eager Test `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em`
* `On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Exploratory Study `_
* `On the diffusion of test smells and their relationship with test code quality of Java projects `_ :octicon:`graph;1em`
* `On the distribution of test smells in open source Android applications: an exploratory study `_ :octicon:`graph;1em`
* `On the influence of Test Smells on Test Coverage `_
* `On the interplay between software testing and evolution and its effect on program comprehension `_ :octicon:`comment-discussion;1em`
* `On the test smells detection: an empirical study on the jnose test accuracy `_ :octicon:`graph;1em`
* `On the use of test smells for prediction of flaky tests `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em`
* `PyNose: A Test Smell Detector For Python `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em`
* `Refactoring Test Code `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em`
* `SoCRATES: Scala radar for test smells `_ :octicon:`file-code;1em`
* `Software Unit Test Smells `_ :octicon:`file-code;1em`
* `Strategies for avoiding text fixture smells during software evolution `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em`
* `Test Smell Detection Tools: A Systematic Mapping Study `_
* `TestQ: Exploring Structural and Maintenance Characteristics of Unit Test Suites `_
* `The secret life of test smells-an empirical study on test smell evolution and maintenance `_ :octicon:`graph;1em`
* `Towards Automated Tools for Detecting Test Smells: An Empirical Investigation into the Nature of Test Smells `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em`
* `What We Know About Smells in Software Test Code `_
* `What the Smell? An Empirical Investigation on the Distribution and Severity of Test Smells in Open Source Android Applications `_ :octicon:`graph;1em`
* `Why do builds fail?—A conceptual replication study `_
* `tsDetect: an open source test smells detection tool `_
* `xUnit test patterns: Refactoring test code `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em`